Web resources are virtual files that are stored in the Microsoft Dynamics CRM database and that you can retrieve by using a unique URL address.
HTML Web Resources
Use webpage (HTML) web resources to create user interface elements for client extensions. Because an HTML web resource is just streamed to the user's browser, it can include any content that is rendered on the user's browser.
Basic structure of an HTML Web Resource and related web resources
The Dynamics CRM SDK provides sample Web Resource files. The example Microsoft provides consists of an HTML Web Resource named ShowData.htm. That HTML file references other web resources to dynamically load XML-based data and to set the output style. The image below provides the code and shows how the web resources are connected to work together. Note: Script.js references a file named Transform.xsl. That XSLT file is not shown in the diagram but it's available in the CRM SDK along with the other sample files.
Pass record object-type code and unique identifier as parameters
When adding an HTML Web Resource to a form, you have the option of passing to it contextual information about the current record as a set of query string parameters. The parameters passed by using the option "Pass record object-type code and unique identifier as parameters" result in a query string similar to the following:
To parse the parameter string (to get a parameter value), you can use this function:
/// <summary>Parses query string values passed to the page and returns the value for the requested parameter or 'null'</summary>
/// <param name="parameter" type="String">The parameter value to look for</param>
/// <returns type="String" />
function getQueryStringParameter(parameter) {
var query = window.location.search.substring(1);
var params = query.split("&");
for (var i = 0; i < params.length; i++) {
var pair = params[i].split("=");
if (pair[0] == parameter) {
return pair[1];
}
}
return "null";
}
Web Resources
Web resources are virtual files that are stored in the Microsoft Dynamics CRM database and that you can retrieve by using a unique URL address.HTML Web Resources
Use webpage (HTML) web resources to create user interface elements for client extensions. Because an HTML web resource is just streamed to the user's browser, it can include any content that is rendered on the user's browser.Basic structure of an HTML Web Resource and related web resources
The Dynamics CRM SDK provides sample Web Resource files. The example Microsoft provides consists of an HTML Web Resource named ShowData.htm. That HTML file references other web resources to dynamically load XML-based data and to set the output style. The image below provides the code and shows how the web resources are connected to work together.Note: Script.js references a file named Transform.xsl. That XSLT file is not shown in the diagram but it's available in the CRM SDK along with the other sample files.
Links
Webpage (HTML) web resourcesHTML Web Resource templates / examples
<!DOCTYPE html> <html> <head> <title>HTML Web Resource Example</title> <script src="~/WebResources/ClientGlobalContext.js.aspx" type="text/javascript"></script> <script src="../Common/jquery1.11.1.min.js"></script> <script src="../Pages/Scripts/Functions.js" type="text/javascript"></script> <link href="../Pages/CSS/Styles.css" rel="stylesheet" type="text/css" /> </head> <body onload="MyNamespace.showData()"> <div id="results" /> </body> </html>Pass record object-type code and unique identifier as parameters
When adding an HTML Web Resource to a form, you have the option of passing to it contextual information about the current record as a set of query string parameters. The parameters passed by using the option "Pass record object-type code and unique identifier as parameters" result in a query string similar to the following:orglcid=1033&orgname=contoso&userlcid=1033&type=10036&typename=cc_survey&id={BD70050B-33A3-E411-98B9-6C3BE5A8AB9C}
To parse the parameter string (to get a parameter value), you can use this function:
/// <summary>Parses query string values passed to the page and returns the value for the requested parameter or 'null'</summary> /// <param name="parameter" type="String">The parameter value to look for</param> /// <returns type="String" /> function getQueryStringParameter(parameter) { var query = window.location.search.substring(1); var params = query.split("&"); for (var i = 0; i < params.length; i++) { var pair = params[i].split("="); if (pair[0] == parameter) { return pair[1]; } } return "null"; }.